package com.fangrui.service.impl;

import com.fangrui.mapper.DeptMapper;
import com.fangrui.pojo.Dept;
import com.fangrui.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

//
// Created by ✎﹏ℳ๓独赏☆独醉 on 2025/4/22 18:19.
//
@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptMapper;
    @Override
    public List<Dept> getAllDept() {
        return deptMapper.getAllDept();
    }

    @Override
    public int deleteDept(Integer id) {
        return deptMapper.deleteDept(id);
    }

    @Override
    public int addDept(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        return deptMapper.addDept(dept);
    }

    @Override
    public Dept getDept(Integer id) {
        return deptMapper.getDept(id);
    }

    @Override
    public int updateDept(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        return deptMapper.updateDept(dept);
    }

    @Override
    public Dept getDept(String name) {
        return deptMapper.getDeptByName(name);
    }

    @Override
    public int deleteEmpByDeptId(Integer id) {
        return deptMapper.deleteEmpByDeptId(id);
    }
}
